package com.bjwl.modules.app.controller;

import com.bjwl.common.utils.R;
import com.bjwl.modules.app.pojo.NoticeVO;
import com.bjwl.modules.app.pojo.UserMessageEntity;
import com.bjwl.modules.app.services.NoticeAppService;
import com.bjwl.modules.app.services.UserMessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 作者 Administrator<br/>
 * 创建时间: 2021/11/28<br/>
 * 描述: <br/>
 */
@RestController
@RequestMapping("app/home")
public class HomeAppController {
    @Autowired
    private UserMessageService userMessageService;

    @Autowired
    private NoticeAppService noticeAppService;

    @RequestMapping("/message")
    public R getUserMessage(String userId) {
        List<UserMessageEntity> datas = userMessageService.getMessageByUser(userId);
        return R.ok().put("data", datas);
    }

    @RequestMapping("/updateMessageFlag")
    public R updateMessageFlag(String messageId){
        userMessageService.updateMessageFlag(messageId);
        return R.ok("数据已经更新！");
    }

    @RequestMapping("/notices")
    public R getNotices(){
      List<NoticeVO> datas= noticeAppService.getList();
      return R.ok().put("data",datas);
    }

    @RequestMapping("/noticesContent")
    public R getNoticeContentById(String noticeId){
        String content = noticeAppService.getNoticeContentById(noticeId);

        return R.ok().put("data",content);
    }
}
